Import('rtconfig')
import os
from building import *

#get current directory
cwd = GetCurrentDir()

CPPDEFINES=[]

# Update include path
path = [ os.path.join(cwd, 'debug_console'), os.path.join(cwd, 'touch'), os.path.join(cwd, 'usb'), os.path.join(cwd, 'dma_mgr')]

# The set of source files associated with this SConscript file.
src = []

src += [ os.path.join(cwd, 'debug_console', 'hpm_debug_console.c') ]
src += [ os.path.join(cwd, 'dma_mgr', 'hpm_dma_mgr.c') ]

if GetDepend(['BSP_USING_TOUCH_GT9xx']):
	src += [os.path.join(cwd, 'touch', 'gt9xx', 'hpm_touch_gt9xx.c') ]
	src += [os.path.join(cwd, 'touch', 'gt9xx', 'hpm_gt9xx.c') ]
	path += [ os.path.join(cwd, 'touch', 'gt9xx') ]
	CPPDEFINES += ['CONFIG_TOUCH_GT9XX=1']
if GetDepend(['BSP_USING_TOUCH_FT5406']):
	src += [ os.path.join(cwd, 'touch', 'ft5406', 'hpm_touch_ft5406.c') ]
	src += [ os.path.join(cwd, 'touch', 'ft5406', 'hpm_ft5406.c') ]
	path += [ os.path.join(cwd, 'touch', 'ft5406') ]
	CPPDEFINES += ['CONFIG_TOUCH_FT5406=1']
if GetDepend(['BSP_USING_USB_DEVICE']):
	src += [ os.path.join(cwd, 'usb', 'device', 'hpm_usb_device.c') ]
	path += [ os.path.join(cwd, 'usb', 'device') ]
if GetDepend(['BSP_USING_USB_HOST']):
	src += [ os.path.join(cwd, 'usb', 'host', 'hpm_usb_host.c') ]
	path += [ os.path.join(cwd, 'usb', 'host') ]
	CPPDEFINES += ['USB_HOST_MCU_CORE=HPM_CORE0']
if GetDepend(['BSP_USING_ETH0']):
	if GetDepend(['BSP_USING_ENET_PHY_DP83867']):
	    src += [ os.path.join(cwd, 'enet_phy/dp83867/hpm_dp83867.c') ]
	    path += [ os.path.join(cwd, 'enet_phy') ]
	    path += [ os.path.join(cwd, 'enet_phy/dp83867') ]
	    CPPDEFINES += ['__USE_DP83867=1']
if GetDepend(['BSP_USING_ETH1']):
	if GetDepend(['BSP_USING_ENET_PHY_DP83848']):
	    src += [ os.path.join(cwd, 'enet_phy/dp83848/hpm_dp83848.c') ]
	    path += [ os.path.join(cwd, 'enet_phy') ]
	    path += [ os.path.join(cwd, 'enet_phy/dp83848') ]
	    CPPDEFINES += ['__USE_DP83848=1']
if GetDepend(['BSP_USING_ETH0']):
	if GetDepend(['BSP_USING_ENET_PHY_RTL8211']):
	    src += [ os.path.join(cwd, 'enet_phy/rtl8211/hpm_rtl8211.c') ]
	    path += [ os.path.join(cwd, 'enet_phy') ]
	    path += [ os.path.join(cwd, 'enet_phy/rtl8211') ]
	    CPPDEFINES += ['__USE_RTL8211=1']
	if GetDepend(['BSP_USING_ENET_PHY_RTL8201']):
	    src += [ os.path.join(cwd, 'enet_phy/rtl8201/hpm_rtl8201.c') ]
	    path += [ os.path.join(cwd, 'enet_phy') ]
	    path += [ os.path.join(cwd, 'enet_phy/rtl8201') ]
	    CPPDEFINES += ['__USE_RTL8201=1']
if GetDepend(['BSP_USING_ETH1']):
	if GetDepend(['BSP_USING_ENET_PHY_RTL8201']):
	    src += [ os.path.join(cwd, 'enet_phy/rtl8201/hpm_rtl8201.c') ]
	    path += [ os.path.join(cwd, 'enet_phy') ]
	    path += [ os.path.join(cwd, 'enet_phy/rtl8201') ]
	    CPPDEFINES += ['__USE_RTL8201=1']
	if GetDepend(['BSP_USING_ENET_PHY_LAN8720']):
	    src += [ os.path.join(cwd, 'enet_phy/lan8720/hpm_lan8720.c') ]
	    path += [ os.path.join(cwd, 'enet_phy') ]
	    path += [ os.path.join(cwd, 'enet_phy/lan8720') ]
	    CPPDEFINES += ['__USE_LAN8720=1']
if GetDepend(['BSP_USING_CAMERA']):
	path += [ os.path.join(cwd, 'camera') ]
if GetDepend(['BSP_USING_CAMERA_MT9M114']):
	src += [os.path.join(cwd, 'camera', 'mt9m114', 'hpm_mt9m114.c') ]
	src += [os.path.join(cwd, 'camera', 'mt9m114', 'hpm_camera_mt9m114.c') ]
	path += [ os.path.join(cwd, 'camera', 'mt9m114') ]
	CPPDEFINES += ['CONFIG_CAMERA_MT9M114=1']
if GetDepend(['BSP_USING_CAMERA_OV5640']):
	src += [os.path.join(cwd, 'camera', 'ov5640', 'hpm_camera_ov5640.c') ]
	src += [os.path.join(cwd, 'camera', 'ov5640', 'hpm_ov5640.c') ]
	path += [ os.path.join(cwd, 'camera', 'ov5640') ]
	CPPDEFINES += ['CONFIG_CAMERA_OV5640=1']
if GetDepend(['BSP_USING_CAMERA_OV7725']):
	src += [os.path.join(cwd, 'camera', 'ov7725', 'hpm_camera_ov7725.c') ]
	src += [os.path.join(cwd, 'camera', 'ov7725', 'hpm_ov7725.c') ]
	path += [ os.path.join(cwd, 'camera', 'ov7725') ]
	CPPDEFINES += ['CONFIG_CAMERA_OV7725=1']
if GetDepend(['BSP_USING_PANEL']):
	path += [ os.path.join(cwd, 'panel') ]
	src += [os.path.join(cwd, 'panel', 'hpm_panel.c') ]
	CPPDEFINES += ['CONFIG_HPM_PANEL']
if GetDepend(['BSP_USEING_PANEL_RGB_TM070RDH13']):
	src += [os.path.join(cwd, 'panel', 'panels', 'tm070rdh13.c') ]
	path += [ os.path.join(cwd, 'panel', 'panels') ]
	CPPDEFINES += ['PANEL_SIZE_WIDTH=800']
	CPPDEFINES += ['PANEL_SIZE_HEIGHT=480']
	CPPDEFINES += ['CONFIG_PANEL_RGB_TM070RDH13=1']
if GetDepend(['BSP_USEING_PANEL_MIPI_MC10128007_31B']):
	src += [os.path.join(cwd, 'panel', 'panels', 'mc10128007_31b.c') ]
	path += [ os.path.join(cwd, 'panel', 'panels') ]
	CPPDEFINES += ['PANEL_SIZE_WIDTH=800']
	CPPDEFINES += ['PANEL_SIZE_HEIGHT=1280']
	CPPDEFINES += ['CONFIG_PANEL_MIPI_MC10128007_31B=1']
if GetDepend(['BSP_USEING_PANEL_LVDS_TM103XDGP01']):
	src += [os.path.join(cwd, 'panel', 'panels', 'tm103xdgp01.c') ]
	path += [ os.path.join(cwd, 'panel', 'panels') ]
	CPPDEFINES += ['PANEL_SIZE_WIDTH=1920']
	CPPDEFINES += ['PANEL_SIZE_HEIGHT=720']
	CPPDEFINES += ['CONFIG_PANEL_LVDS_TM103XDGP01=1']
if GetDepend(['BSP_USEING_PANEL_LVDS_CC10128007']):
	src += [os.path.join(cwd, 'panel', 'panels', 'cc10128007.c') ]
	path += [ os.path.join(cwd, 'panel', 'panels') ]
	CPPDEFINES += ['PANEL_SIZE_WIDTH=800']
	CPPDEFINES += ['PANEL_SIZE_HEIGHT=1280']
	CPPDEFINES += ['CONFIG_PANEL_LVDS_CC10128007=1']

group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, CPPDEFINES=CPPDEFINES)

Return ('group')
